import { msg } from './util.js'

// 基础URL
// let BASE_URL = 'http://175.178.119.130:8701'

const request = (options = {}) => {
  return new Promise((resolve, reject) => {
    let BASE_URL = 'http://127.0.0.1:8848';
    uni.request({
      url: BASE_URL + options.url,
      method: options.method || 'GET',
      data: options.data || {},
      timeout: 80000,
      success: (res) => {
        console.log('成功收到响应：', res.data);
		// console.log("输出的url是:",options);
        resolve(res.data);
      },
      fail: (err) => {
        console.log('请求失败：', err);
        msg('请求接口失败');
        reject(err);
      }
    });
  });
};


// 导出
export {request}